//package com.zws.cucumber.optimization.socket.wiremock;
//
//import com.github.tomakehurst.wiremock.core.FaultInjector;
//import com.github.tomakehurst.wiremock.jetty9.JettyFaultInjectorFactory;
//import com.github.tomakehurst.wiremock.jetty9.JettyUtils;
//import com.github.tomakehurst.wiremock.servlet.FaultInjectorFactory;
//import com.github.tomakehurst.wiremock.servlet.NoFaultInjector;
//import wiremock.javax.servlet.http.HttpServletRequest;
//import wiremock.javax.servlet.http.HttpServletResponse;
//import wiremock.org.eclipse.jetty.io.ChannelEndPoint;
//import wiremock.org.eclipse.jetty.io.EndPoint;
//import wiremock.org.eclipse.jetty.server.HttpChannel;
//import wiremock.org.eclipse.jetty.server.LocalConnector;
//import wiremock.org.eclipse.jetty.server.Response;
//
//public class ZwsSocketFaultInjectorFactory implements FaultInjectorFactory {
//
//    private FaultInjectorFactory origin = new JettyFaultInjectorFactory();
//
//    @Override
//    public FaultInjector buildFaultInjector(HttpServletRequest request, HttpServletResponse response) {
//        Response resp = JettyUtils.unwrapResponse(response);
//        HttpChannel httpChannel = resp.getHttpOutput().getHttpChannel();
//        EndPoint ep = httpChannel.getEndPoint();
//        if (ep instanceof ChannelEndPoint) {
//            return origin.buildFaultInjector(request, response);
//
//        } else if (ep instanceof LocalConnector.LocalEndPoint) {
//            return new ZwsSocketFaultInjector(response);
//
//        } else {
//            return new NoFaultInjector(response);
//        }
//    }
//}
